package Eyjafjalla.card.skill;

import Eyjafjalla.action.CloudReflectionAction;
import Eyjafjalla.action.RetainCloudAction;
import Eyjafjalla.card.AbstractEyjafjallaCard;
import Eyjafjalla.card.status.Cloud_Eyjafjalla;
import Eyjafjalla.modcore.EyjafjallaTag;
import com.badlogic.gdx.Gdx;
import com.megacrit.cardcrawl.actions.common.DrawCardAction;
import com.megacrit.cardcrawl.actions.watcher.ChooseOneAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;

import java.util.ArrayList;

public class Songs_Eyjafjalla extends AbstractEyjafjallaCard {
    public static final String ID = "Songs_Eyjafjalla";
    private static final CardStrings cardStrings;

    public ArrayList<AbstractCard> previews;
    float timer = 1f;
    int index = 1;

    @Override
    public void update() {
        if(previews!=null){
            if(this.cardsToPreview == null && previews.size()>0){
                index = 0;
                this.cardsToPreview = previews.get(1);
            }
            if(timer>0f){
                timer -= Gdx.graphics.getDeltaTime();
            }
            else{
                timer = 1f;
                index++;
                if(index<previews.size()){
                    this.cardsToPreview = previews.get(index);
                }
                else{
                    if(previews.size()>0){
                        index = 0;
                        this.cardsToPreview = previews.get(index);
                    }
                    else
                        this.cardsToPreview = null;
                }
            }
        }
        super.update();
    }

    public Songs_Eyjafjalla(){
        super(ID, cardStrings.NAME,0,cardStrings.DESCRIPTION,CardType.SKILL,CardColor.COLORLESS,CardRarity.SPECIAL,CardTarget.NONE);
        this.exhaust = true;
        this.previews = new ArrayList<>();
        previews.add(new SongMary_Eyjafjalla());
        previews.add(new SongFarmer_Eyjafjalla());
        previews.add(new SongBoat_Eyjafjalla());
    }

    @Override
    public AbstractCard makeCopy() {
        return new Songs_Eyjafjalla();
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        ArrayList<AbstractCard> choices = new ArrayList<>();
        choices.add(new SongMary_Eyjafjalla());
        choices.add(new SongFarmer_Eyjafjalla());
        choices.add(new SongBoat_Eyjafjalla());
        addToBot(new ChooseOneAction(choices));
    }

    @Override
    public boolean canUpgrade() {
        return !this.upgraded;
    }

    @Override
    public void upgrade() {
        if(!this.upgraded){
            upgradeName();
        }
    }

    static {
        cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    }
}







